#include<iostream>
#include<Vector>
#include<algorithm>
using namespace std;


void add(vector<int>& diff, int l, int r, int val)
{
	diff[l] += val;
	diff[r + 1] -= val;
}

int main()
{
	int n, q; cin >> n >> q;

	vector<int>diff(n + 2);

	while (q--)
	{
		int l, r; cin >> l >> r;
		add(diff, l, r, 1);
	}

	for (int i = 1; i <= n; i++)diff[i] += diff[i - 1];

	sort(diff.begin() + 1, diff.end() - 1);

	int ret = diff[(1 + n) >> 1];
	cout << ret << endl;
	return 0;

}
